package project_model;

/**
 * BridgeTest
 *
 * @author Syzer
 * @Description 桥接模式
 * @Date 2021/7/9 12:40
 */
public class BridgeTest {

    private interface Target {
        void show();
    }

    private static class TargetImpl implements Target {
        @Override
        public void show() {
            System.out.println("显示");
        }
    }

    private abstract static class Bridge {
        protected Target target;

        public Bridge(Target target) {
            this.target = target;
        }

        protected abstract void get();
    }

    private static class BridgeImpl extends Bridge {
        public BridgeImpl(Target target) {
            super(target);
        }

        @Override
        protected void get() {
            System.out.println("扩展");
            super.target.show();
        }
    }

    public static void main(String[] args) {
        BridgeImpl bridge = new BridgeImpl(new TargetImpl());
        bridge.get();
    }
}
